<script setup>
import { useThemeStore } from '@/stores/theme';
const theme = useThemeStore()
</script>

<template>
  <label class="switch">
    <input type="checkbox" :checked="theme.isDark" @change="theme.changeTheme">
    <span class="slider"></span>
  </label>
</template>

<style scoped>
.switch {
  position: relative;
  display: block;
  width: 4rem;
  height: 2rem;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #f4f4f5;
  transition: 0.4s;
  border-radius: 60px;
  box-shadow: 3px 3px 5px rgba(0, 0, 0, 0.5);
}

.slider::before {
  position: absolute;
  content: "";
  height: 1.4rem;
  width: 1.4rem;
  border-radius: 50%;
  left: 0.3rem;
  top: 50%;
  transform: translateY(-50%);
  background: linear-gradient(45deg, #ff0080, #ff8c00 70%);
  transition: 0.4s;
}

input:checked+.slider {
  background: #303136;
}

input:checked+.slider::before {
  left: calc(100% - (1.4rem + 0.3rem));
  background: #303136;
  box-shadow: inset -3px -2px 5px -2px #8983f7, inset -10px -4px 0 0 #a3dafb;
}
</style>